<#assign ctx="${rc.contextPath}">
<html>
<head>
    <title>代码生成</title>
    <link type="text/css" rel="stylesheet" href="${ctx}/static/dialog/component.css"/>
    <style>
        .bottom6 {
            margin-bottom: 6px;
        }
    </style>
    <script type="text/javascript">
        var fileName;
        function create() {
            if ($("#frmEdit").form('validate') && checkForm("frmEdit")) {
                var data = $("#frmEdit").serializeObject();
                Load();
                $.ajax({
                    type: "POST",
                    url: $("#frmEdit").attr('action'),
                    data: data,
                    dataType: 'json',
                    success: function (result) {
                        dispalyLoad();
                        successMsg(result.message);
                        if (result.status == 200) {
                            fileName = result.content;
                        }
                    }
                });
            }
        }

        function download() {
            if (fileName != undefined) {
                window.location.href = "${ctx}/zipRoot/" + fileName;
            }
        }

        function edit() {
            window.location.href = "${ctx}/kit/code/template";
        }
    </script>
</head>

<body>
<div class="breadcrumb">开发工具 > 代码生成工具</div>

<form class="form-horizontal form-edit" id="frmEdit" action="${ctx}/kit/code/build">
    <fieldset class="dg-fieldset">
        <legend>目录设置</legend>
        <div class="form-item">
            <div class="form-lab">目录结构：</div>
            <div class="form-field">
                <span class="must">*</span>
                <input class="easyui-validatebox text" type="text" id="basePackage" name="basePackage"
                       value="com.jk" data-options="required:true"/>
            </div>
        </div>

        <div class="form-item">
            <div class="form-lab">命名空间：</div>
            <div class="form-field">
                <span class="must">*</span>
                <input class="easyui-validatebox text" type="text" id="namespace" name="namespace"
                       value="account" data-options="required:true"/>
            </div>
        </div>

    <#--<div class="form-item">-->
    <#--<div class="form-lab">输出目录：</div>-->
    <#--<div class="form-field">-->
    <#--<span class="must">*</span>-->
    <#--<input class="easyui-validatebox text" type="text" id="outRoot" name="outRoot"-->
    <#--value="E:\generator-output" data-options="required:true"/>-->
    <#--</div>-->
    <#--</div>-->
    </fieldset>

    <fieldset class="dg-fieldset">
        <legend>数据库设置</legend>
        <div class="form-item">
            <div class="form-lab">地址：</div>
            <div class="form-field">
                <span class="must">*</span>
                <input class="easyui-validatebox text" type="text" id="jdbcUrl" name="jdbcUrl"
                       data-options="required:true"/> <a class="md-trigger" data-modal="modal-detail">数据库配置说明</a>
            </div>
        </div>

        <div class="form-item">
            <div class="form-lab">用户名：</div>
            <div class="form-field">
                <span class="must">*</span>
                <input class="easyui-validatebox text" type="text" id="jdbcUsername" name="jdbcUsername"
                       data-options="required:true"/>
            </div>
        </div>

        <div class="form-item">
            <div class="form-lab">密码：</div>
            <div class="form-field">
                <span class="must">*</span>
                <input class="easyui-validatebox text" type="text" id="jdbcPassword" name="jdbcPassword"
                       data-options="required:true"/>
            </div>
        </div>

        <div class="form-item">
            <div class="form-lab">驱动：</div>
            <div class="form-field">
                <span class="must">*</span>
                <input class="easyui-validatebox text" type="text" id="jdbcDriver" name="jdbcDriver"
                       value="com.mysql.jdbc.Driver" data-options="required:true"/>
            </div>
        </div>

        <div class="form-item">
            <div class="form-lab">表名：</div>
            <div class="form-field">
                <input class="text" type="text" id="tableName" name="tableName"
                       value="acc_department"/> <span class="gray">为空则生成全部</span>
            </div>
        </div>
    </fieldset>

    <div class="form-item">
        <div class="form-lab">
            <input class="btn btn-primary" type="button" onclick="edit()" value="模板编辑"/>
        </div>
        <div class="form-lab">
            <input class="btn btn-primary" type="button" onclick="create()" value="生成"/>
        </div>
        <div class="form-lab">
            <input class="btn btn-primary" type="button" onclick="download()" value="下载"/>
        </div>
    </div>
</form>

<div class="md-modal md-effect-2" id="modal-detail">
    <div class="md-content">
        <h3>驱动配置说明</h3>

        <div>
            <div class="bottom6">
                <h4>Mysql</h4>

                <div>地址：jdbc:mysql://localhost:3306/database</div>
                <div>驱动：com.mysql.jdbc.Driver</div>
            </div>

            <div class="bottom6">
                <h4>Oracle</h4>

                <div>地址：jdbc:oracle:thin:@192.168.0.177:1521:[sid]</div>
                <div>驱动：oracle.jdbc.driver.OracleDriver</div>
            </div>

            <div class="bottom6">
                <h4>SQLServer2005</h4>

                <div>地址：jdbc:sqlserver://192.168.0.98:1433;DatabaseName=[database]</div>
                <div>驱动：com.microsoft.sqlserver.jdbc.SQLServerDriver</div>
            </div class="bottom6">

            <div class="bottom6">
                <h4>PostgreSql</h4>

                <div>地址：jdbc:postgresql://localhost/[database]</div>
                <div>驱动：org.postgresql.Driver</div>
            </div>

            <div class="bottom6">
                <h4>DB2</h4>

                <div>地址：jdbc:db2://localhost:5000/[database]</div>
                <div>驱动：com.ibm.db2.jdbc.app.DB2Driver</div>
            </div>

            <button class="md-close hide">关闭</button>
        </div>
    </div>
</div>
<div class="md-overlay"></div>

<script type="text/javascript" src="${ctx}/static/dialog/classie.js"></script>
<script type="text/javascript" src="${ctx}/static/dialog/modalEffects.js"></script>
</body>
</html>
